#================================================================
# Measuring Knowledge of Parties' Legislative Seat Shares
# Lee, Haime & Stevenson (2016)
# Replication: Appendix Figure B
#================================================================
# setwd("~/DIRECTORY")  # set your directory

require("graphics")
library(foreign)
rm(list = ls(all = TRUE))

#========================================
# APPENDIX Figure B: UK 
#========================================

data<-read.dta ("figureB_UK.dta")

seats_UK <- with(data, data.frame(sizepercent_dup, sizepercent_cons, sizepercent_lab, sizepercent_libdem, sizepercent_sdlp, sizepercent_snp, 
                   sizepercent_pc,sizepercent_ukip, sizepercent_green, sizepercent_sf, sizepercent_uup,sizepercent_alliance ))

# Change names for the graph
colnames(seats_UK) <- c("DUP\n1.2%", "Conservative\n42.9%", "Labour\n41.4%", "Lib Dem\n4%", 
                     "SDLP\n0.5", "SNP\n8%", "PC\n0.5%", "UKIP\n0.3%", "Green\n0.2%", 
                     "SF 0.8%", "UUP\n0% (n/a)", "Alliance\n0% (n/a)")

stars(seats_UK, locations =  c(0,0) , radius = FALSE, key.loc = c(0, 0), lty = 7)

#========================================
# APPENDIX Figure B: DENMARK 
#========================================

data<-read.dta ("figureB_DK.dta")

seats_DK<- with(data, data.frame(sizepercent_socdem, sizepercent_ven,  sizepercent_danfol, 
                   sizepercent_enh, sizepercent_liball, sizepercent_socfol, sizepercent_radven, 
                   sizepercent_alt,  sizepercent_konfol, sizepercent_kridem))

# Change names for the graph
colnames(seats_DK) <- c("Soc Dem\n25.1%", "V\n20.7%", "DPP\n18.1%",
                     "Enh\n8.4%", "Lib All\n7.7%", "SPP\n5.7%", "RV\n5.4%",
                     "Alt\n4.28%", "CP\n3.7%",  "CD\n0.9%")

stars(seats_DK, locations =  c(0,0) , radius = FALSE, key.loc = c(0, 0), lty = 7)

#========================================
# APPENDIX Figure B: combined 
#========================================

pdf("figureB.pdf", width = 10, height = 4.5)
par(mfrow = c(1,2),  oma = c(0, 0, 2, 0))
stars(seats_UK, locations =  c(0,0) , radius = FALSE, key.loc = c(0, 0), lty = 7)
mtext(text="United Kingdom", line=4, cex=1.3, font=2)
stars(seats_DK, locations =  c(0,0) , radius = FALSE, key.loc = c(0, 0), lty = 7)
mtext(text="Denmark", line=4, cex=1.3, font=2)
dev.off()


#--END